<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div>dadsada</div>
</body>
<script>
    var a = " ";
    var b = "null ";
    var c = "asdas ";
    var d = "adasd 1";
    // 从字符串中提取指定长度的字符串
    console.log(d.substr(d.length - 1, 1))
    // 从字符串中提取指定下标的字符串
    console.log(d.substring(0, d.length - 1))
    // 字符串截取空格前的子字符串
    console.log(d.substring(0, d.length - 1).trim().length);
    // 判断字符串中间是否有空格
    if (d.trim().lastIndexOf("") == -1) {
        console.log("中间无空格");
    } else {
        console.log("中间有空格");
    }

    console.log(kongge2(a));
    console.log(kongge2(b));
    console.log(kongge2(c));


    // 判断字符串是否为空或空格或//n
    function kongge2(test) {
        if (test.match(/^\s*$/)) {
            return false;
        } else {
            return true;
        }
    }
</script>

</html>